<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Services\CourseTypeService;
use Illuminate\Http\Request;

/**
 * @property CourseTypeService $courseTypeService
 */
class CourseTypeController extends BaseController
{
    public function __construct(CourseTypeService $courseTypeService)
    {
        $this->courseTypeService = $courseTypeService;
    }

    //
    public function list(Request $request)
    {
        $result = $this->courseTypeService->getTypeList($request->get('sid',1));
        if (!$result) {
            return $this->fail('获取失败');
        }

        return $this->success($result);
    }

    public function detail(Request $request)
    {
        $result = $this->courseTypeService->getTypeDetail($request->all());
        if (!$result) {
            return $this->fail('获取失败');
        }

        return $this->success($result);
    }

    public function questionDetail(Request $request)
    {
        $result = $this->courseTypeService->questionDetail($request->get('qid',1));
        if (!$result) {
            return $this->fail('获取失败');
        }

        return $this->success($result);
    }
}
